package org.scirp.ijmis.service.personpaper.impl;

import java.util.List;

import org.scirp.ijmis.dao.personpaper.IOperationlogDAO;
import org.scirp.ijmis.dao.personpaper.IPaperStatusDAO;
import org.scirp.ijmis.dao.personpaper.IStatusDAO;
import org.scirp.ijmis.po.personpaper.TOperationlog;
import org.scirp.ijmis.po.personpaper.TPaperinformation;
import org.scirp.ijmis.po.personpaper.TStatusofpaper;
import org.scirp.ijmis.service.personpaper.IPaperStatusService;
import org.scirp.ijmis.util.Pagination;

public class PaperStatusServiceImpl implements IPaperStatusService{

	private IPaperStatusDAO paperStatusDAO;
	private IOperationlogDAO operationlogDAO;



	public Long savePaperStatus(TPaperinformation tpi) {
		Long l=paperStatusDAO.doInsertStartState(tpi);
		TOperationlog tol=new TOperationlog();
		tol.setPaperid(tpi.getPaperid());
		tol.setOperationtime(tpi.getOperatetime());
		tol.setOperationlog("New Paper");
		operationlogDAO.doInsertStartState(tol);
		return l;
	}

	public void deletePaperinformationByPaperId(Long pid) {
		paperStatusDAO.deletePaperinformationByPaperId(pid);
	}

	public int countPaperByStatus(int i, Long journalId) {
		return paperStatusDAO.countPaperByStatus(i,journalId);
	}

	public List<TPaperinformation> selectPaperByStatusId(int statusId,
			Long journalId, Pagination pagination) {
		return paperStatusDAO.selectPaperByStatusId(statusId,journalId,pagination);
	}

	public boolean updatePaperStatus(Long paperId, Long statusId,String remark) {
		return paperStatusDAO.updatePaperStatus(paperId,statusId,remark);
	}

	public int countRemindPaperByStatus(int statusId, Long journalId) {
		return paperStatusDAO.countRemindPaperByStatus(statusId,journalId);
	}

	public int countWarnPaperByStatus(int statusId, Long journalId) {
		return paperStatusDAO.countWarnPaperByStatus(statusId,journalId);
	}

	public String checkOvertime(Long pid) {
		return paperStatusDAO.checkOvertime(pid);
	}

	public boolean updatePaperStatus(Long paperId, Long statusId, String feeType,String remark) {
		return paperStatusDAO.updatePaperStatus(paperId, statusId, feeType,remark);
	}
	
	public boolean updatePaperStatus(Long paperId, Long statusId,Long vol,Long no ,String remark) {
		return paperStatusDAO.updatePaperStatus(paperId, statusId,vol,no,remark);
	}

	public List<TPaperinformation> selectPaperByPaperNo(Long paperno,
			Long journalId) {
		return paperStatusDAO.selectPaperByPaperNo(paperno,journalId);
	}

	@SuppressWarnings("unchecked")
	public List selectPaperByPaperId(Long paperid) {
		return paperStatusDAO.selectPaperByPaperId(paperid);
	}

	@Override
	public int saveNotExistPaperInfo(String date) {
		return paperStatusDAO.saveNotExistPaperInfo(date);
	}



	public List countPaperByAllStatus(List<TStatusofpaper> statusList, Long journalid) {
		return paperStatusDAO.countPaperByAllStatus(statusList,journalid);
	}

	public int countViewPaperByVolNo(Long vol, Long no, Long journalId) {
		return paperStatusDAO.countViewPaperByVolNo(vol,no,journalId);
	}

	public List<TPaperinformation> selectViewPaperByVolNo(Long vol, Long no,
			Long journalId, Pagination pagination) {
		return paperStatusDAO.selectViewPaperByVolNo(vol,no,journalId,pagination);
	}

	public boolean updatePaperStatus(String ids, Long nextStatusId,String name) {
		boolean isSuccess=paperStatusDAO.updatePaperStatus(ids,nextStatusId);
		operationlogDAO.updatePaperStatus(ids,nextStatusId,name);
		return isSuccess;
	}


	public IPaperStatusDAO getPaperStatusDAO() {
		return paperStatusDAO;
	}

	public void setPaperStatusDAO(IPaperStatusDAO paperStatusDAO) {
		this.paperStatusDAO = paperStatusDAO;
	}
	public IOperationlogDAO getOperationlogDAO() {
		return operationlogDAO;
	}

	public void setOperationlogDAO(IOperationlogDAO operationlogDAO) {
		this.operationlogDAO = operationlogDAO;
	}
}
